bitkeeper revision 1.647 (3fd8bc49qQxDHkfovcYSBfQ4p0Fpfg)
authoriap10@striker.cl.cam.ac.uk <iap10@striker.cl.cam.ac.uk>
Thu, 11 Dec 2003 18:49:45 +0000 (18:49 +0000)
committeriap10@striker.cl.cam.ac.uk <iap10@striker.cl.cam.ac.uk>
Thu, 11 Dec 2003 18:49:45 +0000 (18:49 +0000)
Add Mark Williamson's readxenconsolering.py example script which reads
Xen's console out of the buffer ring, making Xen's boot messages available
from within domain 0.

.rootkeys
tools/examples/readxenconsolering.py [new file with mode: 0644]

index 27db4968aa37f8b04ea0384c601e558526e2d828..3686d6eb201fe074e77f72a5c1975dfddaaa83a4 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
@@ -44,6 +44,7 @@
 3fbe2f12ltvweb13kBSsxqzZDAq4sg tools/examples/listdoms.py
 3fca7788tBihusQSq3HJI-YKQTN2iQ tools/examples/mynewdom.py
 3fca7700PVj36cZObaFZlQicRiw1pQ tools/examples/pincpu.py
+3fd8bc48ww3aOqPhYjCr8KGulG0NQQ tools/examples/readxenconsolering.py
 3fccbe068ov0YCxnk-2m4law19QMmA tools/examples/startdom.py
 3fbe2f12Bnt8mwmr1ZCP6HWGS6yvYw tools/examples/stopdom.py
 3f776bd2Xd-dUcPKlPN2vG89VGtfvQ tools/misc/Makefile
diff --git a/tools/examples/readxenconsolering.py b/tools/examples/readxenconsolering.py
new file mode 100644 (file)
index 0000000..0e9305a
--- /dev/null
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2003 by Intel Research Cambridge
+
+# File:   tools/examples/readconsolering.py
+# Author: Mark A Williamson (mark.a.williamson@intel.com)
+# Date:   2003-12-02
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+
+"""Reads out the contents of the console ring
+
+Usage: readconsolering.py [-c]
+The -c option causes the contents to be cleared.
+"""
+
+import sys, Xc # import the Xc Xen Control module
+
+xc = Xc.new() # get a new instance of the control interface
+
+clear_buffer = False
+
+if sys.argv[1:] != []:
+    if sys.argv[1] == "-c":
+        clear_buffer = True
+    else:
+        print >> sys.stderr, "Usage: " + sys.argv[0] + """ [-c]
+       Reads the contents of the console buffer.
+       (specifying -c will also clear current contents)"""
+
+# Get the console ring's contents as a string and print it out.
+# If argument to readconsolering is true then the buffer is cleared as well as
+# fetching the (pre-clearing) contents.
+print xc.readconsolering(clear_buffer)